﻿using FileTransferProtocol;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Sockets;
using System.Threading.Tasks;

namespace TestSender
{
    class Program
    {
        static void Main(string[] args)
        {
            if (!Directory.Exists("LocalPath"))
                throw new Exception("找不到本地路径");

            List<Task> tasks = new List<Task>();

            foreach (var item in Directory.GetFiles("LocalPath"))
            {
                var local_item = item;
                //tasks.Add(Task.Factory.StartNew(() =>
                //{
                TcpClient client = new TcpClient();
                    client.Connect("172.16.10.99", 8030);

                    using (var stream = client.GetStream())
                    {
                        new FileSender().Send(stream, new FileReader(local_item));
                    }
                //}));
            }

            Task.WaitAll(tasks.ToArray());

            Console.ReadLine();
        }
    }
}
